import _request from "../common/_request";
import {Message} from "element-ui";

let api_weixin = {

    // openid
    openid: function ( code, callback) {
        let data = {};
        data.code = code
        _request._get('/weixin/openid', data, function (response) {
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }
            callback(response.data)
        })
    },

    // userinfo
    userinfo: function ( code, callback) {
        let data = {};
        data.code = code
        _request._get('/weixin/userinfo', data, function (response) {
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }
            callback(response.data)
        })
    },

    //活动分享 - 分享
    share: function (callback) {
        let data = {};
        data.share_url = encodeURIComponent(window.location.href);
        _request._get('/activity/share', data, function (response) {
            if (response.code !== _request.success) {
                Message.info(response.msg);
                return;
            }

            callback(response.data)
        })
    },
}


export default api_weixin
